package com.qianwang.shopmsg.util;

import java.util.List;

import net.sf.oval.ConstraintViolation;
import net.sf.oval.Validator;

import com.qianwang.shopmsg.exception.ParamValidateException;
import com.qianwang.shopmsg.param.AbstractParam;

/**
 *  参数校验
 * @author zhanglb
 *
 */
public class OvalUtil {
	
	public static void validate(AbstractParam param) throws ParamValidateException{
		Validator  validator = new Validator();
		List<ConstraintViolation> violations = validator.validate(param);
		if(null != violations && violations.size()>0){
			throw new ParamValidateException(violations.get(0).getMessage());
		}
	}

}
